import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '',
      redirect: '/login'
    },
    {
      path: '/login',
      name: 'login',
      meta: { title: '登录' },
      component: () => import('@/views/login/views-login.vue')
    },
    {
      path: '/register',
      name: 'register',
      meta: { title: '注册' },
      component: () => import('@/views/register/views-register.vue')
    },
    {
      path: '/dashboard',
      redirect: '/dashboard/home',
      component: () => import('@/views/dashboard/views-dashboard.vue'),
      children: [
        {
          path: 'home',
          name: 'home',
          meta: { title: '首页' },
          component: () => import('@/views/home/views-home.vue')
        },
        {
          path: 'md',
          name: 'md',
          meta: { title: 'MD文档' },
          component: () => import('@/views/md/views-md.vue')
        },
        {
          path: 'system-config',
          name: 'system-config',
          meta: { title: '系统设置' },
          redirect: '/dashboard/system-config/role-manager',
          children: [
            {
              path: 'role-manager',
              name: 'role-manager',
              meta: { title: '角色管理' },
              component: () => import('@/views/role-manage/views-role-manage.vue')
            },
            {
              path: 'auth-manager',
              name: 'auth-manager',
              meta: { title: '权限管理' },
              component: () => import('@/views/auth-manage/views-auth-manage.vue')
            },
            {
              path: 'user-manager',
              name: 'user-manager',
              meta: { title: '用户管理' },
              component: () => import('@/views/user-manage/views-user-manage.vue')
            },
            {
              path: 'done-log',
              name: 'done-log',
              meta: { title: '操作日志' },
              component: () => import('@/views/done-log/views-done.vue')
            },
          ]
        },
        {
          path: 'sql-test',
          name: 'sql-test',
          meta: { title: 'SQL调试' },
          component: () => import('@/views/sql-test/views-sql-test.vue')
        },
      ]
    },
    {
      path: '/:catchAll(.*)',
      component: () => import('@/views/error-page/views-404.vue')
    }
  ]
})

export default router
